<template>
  <div class="send-request">
  </div>
</template>

<script>
import { mapState } from 'vuex'
import { getUserChannels } from '@/api/user.js'
import { getItem } from '../../utils/storage'
export default {
  name: 'sendRequest',
  components: {},
  props: {},
  created () {
    this.loadChannels()
  },
  data () {
    return {
      channels: [],
    }
  },
  computed: {
    ...mapState(['user'])
  },
  methods: {
    async loadChannels () {
      try {
        this.$toast.loading({ message: '加载中...', duration: 0, forbidClick: true })
        if (this.user) {
          const { data: res } = await getUserChannels()
          this.channels = res.data.channels
        } else {
          if (getItem('UPDATE_CHANNEL')) {
            this.channels = getItem('UPDATE_CHANNEL')
          } else {
            const { data: res } = await getUserChannels()
            this.channels = res.data.channels
          }
        }
        this.$toast.clear()
      } catch (error) {
        this.$toast.fail('获取失败')
      }
    }
  }
}
</script>

<style lang="less" scoped>
</style>
